package com.demo.config.Interceptor;


import com.demo.util.CheckToken;
import com.demo.util.TokenVo;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.HandlerInterceptor;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@Component
public class UserInterceptor implements HandlerInterceptor {



    public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) throws Exception {
        TokenVo tokenVo = new CheckToken().checkToken(request);
        if (tokenVo != null ){
            return true;
        }
        response.getWriter().print("Access denied");
        return false;
    }

}
